package com.newlink.building.secret.mvp.presenter

import com.newlink.building.common_base.base.BasePresenter
import com.newlink.building.common_base.ext.ss
import com.newlink.building.common_base.model.bean.SecretKeyDeleteRequest
import com.newlink.building.common_base.model.bean.SecretKeyInfoRequest
import com.newlink.building.common_base.model.bean.StatusData
import com.newlink.building.secret.mvp.contract.Module_Secret_SecretKeyContract
import com.newlink.building.secret.mvp.model.Module_Secret_SecretKeyModel

/**
 * Created by xiaodong on 2022/10/2.
 */
class Module_Secret_SecretKeyPresenter : BasePresenter<Module_Secret_SecretKeyContract.Model, Module_Secret_SecretKeyContract.View>(),
    Module_Secret_SecretKeyContract.Presenter {
    override fun createModel(): Module_Secret_SecretKeyContract.Model = Module_Secret_SecretKeyModel()

    override fun getSecretKeyInfo(requestBean: SecretKeyInfoRequest) {
        mModel?.getSecretKeyInfo(requestBean)?.ss(mModel, mView) { result ->
            result?.data?.let { mView?.refreshSecretKeyInfo(it) }
        }
    }

    override fun deleteSecretKey(requestBean: SecretKeyDeleteRequest) {
        mModel?.deleteSecretKey(requestBean)?.ss(mModel, mView) { result ->
            if (result != null) {
                mView?.refreshDeleteStatus(StatusData(result.code == 200))
            }
        }
    }
}